from owl_ai.domain.agent_config_entity import AgentConfigEntity
from owl_ai.service.agent_config_service import AiAgentConfigService
from owl_common.base.model import AjaxResponse
from owl_common.descriptor.serializer import JsonSerializer
from owl_common.descriptor.validator import BodyValidator
from ... import reg


@reg.api.route('/agent/config/add', methods=['POST'])
@BodyValidator()
@JsonSerializer()
def add_agent_config(dto: AgentConfigEntity):
    result = AiAgentConfigService.insert_config(dto)
    response = AjaxResponse.from_success(msg="操作成功")
    return response


@reg.api.route('/agent/config/get', methods=['POST'])
@BodyValidator()
@JsonSerializer()
def get_agent_config(dto: AgentConfigEntity):
    result = AiAgentConfigService.select_config(dto)
    return AjaxResponse.from_success(msg="操作成功", data=result)
